package com.logistics.map.entity.domain;

import com.baomidou.mybatisplus.annotation.IdType;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.TableId;
import java.io.Serializable;

import com.baomidou.mybatisplus.annotation.TableName;
import com.logistics.map.entity.model.MapRouteSave;
import com.logistics.utils.tool.DateUtils;
import com.logistics.utils.tool.StringUtils;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * <p>
 * 
 * </p>
 *
 * @author zhiyu.fan
 * @since 2024-06-03
 */
@Data
@EqualsAndHashCode(callSuper = false)
@TableName("lgs_map_route")
public class MapRoute implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    private String name;

    private String code;

    private Integer mapId;

    private String createOrgCode;

    private String createDepCode;

    private String creator;

    private Date createTime;

    private String updater;

    private Date updateTime;

    public MapRoute(){

    }

    public MapRoute(MapRouteSave save){
        this.id = StringUtils.isNotNull(save.getId()) ? Integer.parseInt(save.getId()) : null;
        this.name = save.getName();
        this.code = save.getCode();
        this.mapId = StringUtils.isNotNull(save.getMapId()) ? Integer.parseInt(save.getMapId()) : null;
        this.createOrgCode = save.getCreateOrgCode();
        this.createDepCode = save.getCreateDepCode();
        this.creator = save.getCreator();
        this.createTime = DateUtils.stringToDateFormat(save.getCreateTime(), DateUtils.YYYY_MM_DD_HH_MM_SS);
        this.updater = save.getUpdater();
        this.updateTime = DateUtils.stringToDateFormat(save.getUpdateTime(), DateUtils.YYYY_MM_DD_HH_MM_SS);
    }

    public static MapRoute build(MapRouteSave save){
        return new MapRoute(save);
    }

}
